package com.hframe.typefilter;

import com.hframe.utils.BytesUtils;
import org.apache.log4j.Logger;


/**
 * ID解密
 *
 * @author Administrator
 */
public class LongBase64Decoder implements FilterRef<Long, Object> {
    static Logger log = Logger.getLogger(LongBase64Decoder.class);

    @Override
    public Long filter(Object object) {
        if (null == object)
            return null;
        if (object instanceof String)
            return decoder((String) object);

        return null;
    }

    public static Long decoder(String val) {
        byte[] data = Base64Decoder.decoderToBytes(val);
        if (null != data) {
            return BytesUtils.getLong(data, 0);
        }
        return null;

    }

}